<?
/*
 * Copyright 2004-2005 Sigve Indregard.
 *
 * This file is part of Laivsys.
 *
 * Laivsys is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Laivsys is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Laivsys; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * $Id: deltakerliste.php 6 2005-07-11 23:14:47Z say $
 */
 
include("../db.php");
include("auth.php");
header("Content-type: text/plain");

$sql="SELECT ID, Navn, YEAR(Fodselsdato), Epost FROM Deltakere WHERE Godkjent=1 AND LaivID=$laivid ORDER BY Navn";
$deltakere=mysql_query($sql);
while ($deltaker=mysql_fetch_assoc($deltakere)) {
	$egen="";
	$karakter="";
	
	$sql="SELECT Egenskap FROM Egenskaper LEFT JOIN Egenskaplinje ON Egenskaper.ID=Egenskaplinje.EgenskapID WHERE DeltakerID=".$deltaker['ID'];
	$egenskaper=mysql_query($sql);
	while ($egenskap=mysql_fetch_row($egenskaper))
		$egen .= $egenskap[0].", ";
	$egen=substr($egen, 0, strlen($egen) -2);
	
	$sql="SELECT Karakteristikk FROM Karakteristikker LEFT JOIN Karakteristikklinje ON Karakteristikker.ID=Karakteristikklinje.KarakteristikkID WHERE DeltakerID=".$deltaker['ID'];
	$karakteristikker=mysql_query($sql);
	while ($karakteristikk=mysql_fetch_row($karakteristikker))
		$karakter .= $karakteristikk[0].", ";
	$karakter=substr($karakter, 0, strlen($karakter) -2);
	
	foreach ($deltaker as $felt)
		echo "\"".$felt."\";";
	echo "\"$egen\";";
	echo "\"$karakter\"\n";
}
?>
